function formatTime(date) {
  var year = date.getFullYear()
  var month = date.getMonth() + 1
  var day = date.getDate()
 
  var hour = date.getHours()
  var minute = date.getMinutes()
  var second = date.getSeconds()
 
  return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute].map(formatNumber).join(':')
 }
/**********************封装request请求*************************/
// const getUrl = " https://test.bjclb.cn/#/"; // 请求地址
const getUrl = "http://192.168.100.250:8780"; // 请求地址
function getData(url, method, data, cb,loadText) { // 请求数据方法
  // wx.showLoading({
  //   title: loadText?loadText:'数据加载中~',
  //   mask: true,
  // })
  wx.request({
    url: getUrl + url + "?token=" + wx.getStorageSync('token') ,
    data: data,
    method: method,
    header: {
      'Content-Type': 'application/json'
    },
    success: function(res) {
      console.log(res);
      if(res.data.code != 0){
        wx.showToast({
          title: res.data.msg,
          icon: 'none',
          duration: 2000
        });
      }
      return typeof cb == "function" && cb(res.data)
    },
    fail: function(res) {
      wx.hideLoading();
      return typeof cb == "function" && cb(false)
    }
  })
}

module.exports = {
  getData: getData,
  getUrl: getUrl
}
